/******************************
* 引用前请确定使用的版本
* Powered By Leo
* 版本号: V2.1.0804
********************************/

/*******************************上传功能专用**********************************/
function OnUploadCompleted(err,url,file,message){
	if(url==''){alert('请正确选择文件上传!\n'+message);return};
    if(err==0){
    	alert('上传成功('+url+')!!       ');
        PG.BrowserFile();
    }else{
    	alert('上传失败!!\n\n原因:'+message+'.      ');
	}
}
/*******************************通行证功能**********************************/
var PST = {
	UserName : '',
	Password : '',
	counter:0,
	
	tabListId : 'myTabs',
	/*内部变量*/
	_isLogin : false,
	_CmdUrl : 'http://my.xmhouse.com/esf/docmd.aspx',
	_LastOpResult : false,/*最后一次操作结果*/
	/* 内容过程调用 */

	loadContent : function(/*String*/fName,/*String*/query,/*String*/ActMenuId){
		if(xPassport.isLogined()){
			PG.loadContent(fName,query);
		}else{
			alert('您还未登录，请先登录！！     ');
			location.href = 'login.html'
		}
		/*if(ActMenuId&&MenuTree)MenuTree.setActivedItem(ActMenuId);*/
	},

	/* 通行证注册　*/
	doRegUser : function(obj,/*form XmlNode*/frmobj){
		obj.disabled = true;
		try{
			var sQuery = Form.serialize(frmobj);
			if(PG.doCmd('RegUser',sQuery,0)==1){
				this.chkLogin('txtUserName','txtPassword','vCode','/my/default.html');
			}
		}catch(e){
			alert(e);
		}
		obj.disabled = false;
	},
	/*运行页面ajax指令*/
	doCmd : function(/*String 命令名*/fCmd,/*String 条件*/sQuery,/*boolean 是否自动返回?*/fIsAlert){
			if(fCmd.indexOf('删除')>-1||fCmd.indexOf('Delete')>-1){
				if(!window.confirm('您将执行['+fCmd+'],此操作(不可恢复)？'))
				return false;
			}
		var q = 'uAction='+encodeURI(fCmd)+'&'+sQuery;
		PG.IsAlert = true;
		var rtnValue = false;
		var myAjax = new Ajax.Request(PST._CmdUrl,{asynchronous:false,parameters: q ,method: 'get',
																	onComplete:function(r){
																		/*处理返回的数据*/
																		alert(1111);
																		rtnValue =  PG.doResult(r.responseText);
																	}});
		return rtnValue;
	},
	/* 页面登录　*/
	chkAdminLogin : function(/*String|Object*/userId,/*String|Object*/pwdId,/*String*/vCode,/*String*/toUrl){
		if(!toUrl) toUrl= '/default.html';
		if(!userId||!pwdId)return;
		var _alert = _window.Open('<img src="/images/default/loading.gif"/>','系统登录中,请稍候...','ismodal=1,width=240,class=VISTA,resize=no');
		userId = Object.isString(userId)?$(userId)['value']:userId;
		pwdId = Object.isString(pwdId)?$(pwdId)['value']:pwdId;
		vCode = Object.isString(vCode)?(($(vCode)==null)?'':$(vCode)['value']):vCode;
		var rtnValue  = false;
		if(userId.length<3||pwdId.length<3){
			alert('对不起！用户名及密码至少3位！！');
		}else{
		var q= 'mLoginUid='+userId+'&mLoginPwd='+pwdId+'&vCode='+vCode;
		new Ajax.Request('/httpchklogin.html',
										{
											asynchronous:false,
											parameters: q ,
											method: 'post',
											onComplete:function(r){
												var text = r.responseText;
												if(text.split(",")[0]==0){
													rtnValue = true;
													if(toUrl==null){
														location.href=document.referer?document.referer:'/my/default.html';
													}else location.href=toUrl;
													_alert = _window.Open('<img src="/images/default/loading.gif"/>','登录成功！转向中,请稍候...','ismodal=1,width=240,class=VISTA,resize=no');
												}else if(text.split(",")[0]==103){
													if($('vCodeLine')) Element.show('vCodeLine');
													rtnValue = false;
													alert(text.split(",")[1]);
												}else{
													rtnValue = false;
													alert(text.split(",")[1]);
												}
											}
										});
		}
		_alert.Hidden();
		return rtnValue;
	},
	openLoginWin : function(){
		var myAjax = new Ajax.Request('/htmls/login.htm?'+Math.random(),{
																	asynchronous:true,
																	method: 'get',
																	onSuccess:function(r){
																		var w = _window.Confirm(r.responseText,'登录','width=260')
																		w.OnOK=function(){
																			if(PST.chkLogin('mLoginUid','mLoginPwd','vCode','#')){
																				alert("祝贺您登录成功!!!");
																				w.Hidden();
																			}
																		}
																	}
																	});
	},
	chkLogin : function(/*String|Object*/userId,/*String|Object*/pwdId,/*String*/vCode,/*String*/toUrl){
		if(!toUrl) toUrl= '/default.html';
		if(!userId||!pwdId)return;
		var _alert = _window.Open('<img src="/images/default/loading.gif"/>','系统登录中,请稍候...','ismodal=1,width=240,class=VISTA,resize=no');
		userId = Object.isString(userId)?$(userId)['value']:userId;
		pwdId = Object.isString(pwdId)?$(pwdId)['value']:pwdId;
		vCode = Object.isString(vCode)?(($(vCode)==null)?'':$(vCode)['value']):vCode;
		if(userId.length<3||pwdId.length<3){
			alert('对不起！用户名及密码至少3位！！');
		}else{
		var q= 'txtUserName='+userId+'&txtPassword='+pwdId+'&vCode='+vCode;
		new Ajax.Request('/httpchklogin.html',
										{
											asynchronous:false,
											parameters: q ,
											method: 'post',
											onComplete:function(r){
												var text = r.responseText;
												if(text.split(",")[0]==0){
													PST._isLogin = true;
													if(toUrl==null){
														location.href=document.referer?document.referer:'/my/default.html';
													}else location.href=toUrl;
													_alert = _window.Open('<img src="/images/default/loading.gif"/>','登录成功！转向中,请稍候...','ismodal=1,width=240,class=VISTA,resize=no');
												}else if(text.split(",")[0]==103){
													if($('vCodeLine')) Element.show('vCodeLine');
													PST._isLogin = false;
													alert(text.split(",")[1]);
												}else{
													PST._isLogin = false;
													alert(text.split(",")[1]);
												}
											}
										});
		}
		_alert.Hidden();
		return this._isLogin;
	},
	LogOut : function(toUrl){
			this._isLogin = false;
			if(toUrl.substring(toUrl.length-1,1)=="/"){toUrl = toUrl.substring(0,toUrl.length-1)}
			dojo.xhrPost({url:"/passport/logout.html",
					 sync : true,
					 error: xPage.doError,
					 load: function(){location.href=toUrl}
			})
			
	},
	doCheckBoxOpen : function(fCb,url,imax,fArg){
		if(PG.IsChecked(fCb,imax)){
			window.open(url+'?'+fCb+'='+PG.getCheckBoxValue(fCb)+'&'+fArg);
		}
	},
	/*执行命令*/
	doCheckBoxCmd : function(fName,fCb,fVal,balert){
		if(PG.IsChecked(fCb)){
			return PG.doCmd(fName,fCb+'='+PG.getCheckBoxValue(fCb)+'&State='+fVal,balert||false);
		}
	},
	/**********************************表单提交保存处理****************************************/
	saveContentCmd : function(fObj,tForm,isAlert){
		try{
			PG.IsAlert = isAlert;
			fObj.disabled=true;
			var d = Form.serialize(tForm);
			var rtnValue = false;
			var myAjax = new Ajax.Request('/aspx/xmlhttppost.aspx',{
																		asynchronous:false, parameters: d ,method: 'post',
																		onComplete:function(r){
																			/*处理返回的数据*/
																			rtnValue =  PST.returnSaveCmdResult(r.responseText);
																	}});
			fObj.disabled=false;
			return rtnValue;
		}catch(e){
			alert(e.message);
			fObj.disabled=false;
			return false;
		}
		return false;
	},
	
	/* 处理 提交数据后返回的代码和消息 */
	returnSaveCmdResult : function(r){
		var arr = r.split(',');
		switch(arr[0])
		{
			case "1":
				if(PG.IsAlert) _window.Alert(arr[1],'提示');
				return true;
			case "2":
				if(PG.IsAlert) _window.Alert(arr[1],'提示');
				return true;
			default:
				alert(arr[1]);
				break;
		}
		return false;
	},
	/*处理 xhr Get方法的结果*/
	doGetResult : function(/*string*/fC){
		xPassport._LastOpResult = xPage.doResult(fC);
	},
	/*处理 xhr Post方法的结果*/
	doPostResult : function(/*string*/fC){
		xPassport._LastOpResult = xPage.doResult(fC);
	}
}
var PG = {
	IsAlert : true,/*是否显示提示信息*/
	MaxSelected :6,
	_FileDialog : null,
	_Path : '/',
	oFCKeditor : null,
	selectObj : {text:null,value:null},
	
	getIEVersion : function (){
		var reg = new RegExp("MSIE ([^;]*);", "i");
		if (reg.test(navigator.appVersion)) return parseInt(RegExp.$1);
		return 0;
	},
	ajaxLogin: function(){
		var w = new _window_({width:400,isModal:true,className:'ajaxlogin'});
		w.loadUrl('用户登录','/ajaxlogin.html');
	},
	LogOut : function(toUrl){
			if(toUrl.substring(toUrl.length-1,1)=="/"){toUrl = toUrl.substring(0,toUrl.length-1)}
			dojo.xhrPost({url:"/logout.html",
					 sync : true,
					 load: function(){location.href=toUrl}
			})
			
	},
	temp : {},
	focus : function(el){
		this.temp[el.id] = el.value;
		el.value = '';
	},
	blur : function(el){
		el.value = this.temp[el.id];
	},
	/**********************************表单提交保存处理.b****************************************/
	saveContentCmd : function(fObj,tForm,isAlert){
		try{
			this.IsAlert = isAlert;
			fObj.disabled=true;
			var d = Form.serialize(tForm);
			var rtnValue = false;
			var myAjax = new Ajax.Request('/aspx/xmlhttppost.aspx',{
																		asynchronous:false, parameters: d ,method: 'post',
																		onComplete:this.returnSaveCmdResult.bind(this,rtnValue)});
			fObj.disabled=false;
			return rtnValue;
		}catch(e){
			alert(e.message);
			fObj.disabled=false;
			return false;
		}
		return false;
	},
	/* 处理 提交数据后返回的代码和消息 */
	returnSaveCmdResult : function(rtnValue,ajax){
		r = ajax.responseText
		var arr = r.split(',');
		switch(arr[0])
		{
			case "1":
				if(this.IsAlert) alert(arr[1],'提示');
				return true;
			case "2":
				if(this.IsAlert) alert(arr[1],'提示');
				return true;
			default:
				alert(arr[1]);
				break;
		}
		return false;
	},
	/**********************************表单提交保存处理.e****************************************/
	openHtmlEditor : function(fnId,height){
		if(height==null) height = 320;
		this.oFCKeditor = new FCKeditor(fnId,"100%",height); 
		this.oFCKeditor.ReplaceTextarea();
		return;
	},
	GetContents : function(fnId){
		if(typeof(FCKeditorAPI)=='undefined'||FCKeditorAPI==null) return ;
		oEditor = FCKeditorAPI.GetInstance(fnId) ;
		if(oEditor)	$(fnId).value = oEditor.GetXHTML(true);
	},
	/* 加载内容divContent */
	loadContent : function(/*String*/fName,/*String*/query){
		this.loadTheContent('divContent',fName,query)
	},
	/* 加载内容 */
	loadTheContent : function(/*Object*/node,/*String*/fName,/*String*/query,bAsyn){

		var q = 'f='+encodeURI(fName)+'&'+query;

		new Ajax.Updater(node,'/aspx/xmlhttp.aspx',{asynchronous:bAsyn&&true,evalScripts:true,parameters: q ,method: 'get',onCreate: function(){
				Element.update(node,'Loadding...');
			}});
			
	},
	loadFuncContent : function(/*function*/callback,/*String*/fName,/*String*/query,bAsyn){
		var q = 'f='+encodeURI(fName)+'&'+query;

		new Ajax.Request('/aspx/xmlhttp.aspx',{asynchronous:bAsyn&&true,evalScripts:true,parameters: q ,method: 'get',onSuccess: callback});
	},
	Replace :function(content,value){
		alert(content);
		alert(content.replace($key/ig,value));
		return content.replace('{0}',value);
	},
	/* 加载内容 */
	loadUrlContent : function(/*Object*/node,/*String*/fUrl,/*String*/query){
		var obj = (Object.isString(node))? this.byId(node):node
		if(!obj){alert('找不到对象['+node+'].');return;}
		var q = query;
		new Ajax.Request(fUrl,{
																	parameters: query ,
																	method: 'get',
																	evalJS: true,
																	onComplete: function(r) {
																		Element.update(obj,r.responseText);
																	}
																	});
		var handle={
			onCreate: function(){
				Element.update(obj,'Loadding...');
			}
		};
		Ajax.Responders.register(handle);
	},
	FileSelect : function(inputObj,ImgObj,title){
		if(document.readyState=='complete'){
			if(Object.isString(inputObj))inputObj = $(inputObj);
			if(Object.isString(ImgObj))ImgObj = $(ImgObj);
			var sFeatures = 'class=NOKIA,button=OK|CANCEL,width=480px,height=400px,resize=0,ismodal=1';
			var sTitle = '选择我的文件';
			var sQuery = 's=' + Math.random();
			new Ajax.Request('/my/MyFiles.html',{
				asynchronous:false,
				parameters: sQuery,
				method: 'get',
				evalJS: false,
				onSuccess: function(r) {
					PG._FileDialog=_window.Open(r.responseText,title, sFeatures);
					PG._FileDialog.OnOK= function(){
						var objValue = $('imgValue');
						if(objValue!=null){
							if(ImgObj!=null)ImgObj.src =objValue.value
							if(inputObj!=null)inputObj.value =objValue.value
							this.Hidden();
						}else{
							alert('对不起！！你还未选择文件！！\n请重新选择你上传的文件！！！');
						}
					}
				}
			});		
		}else{
			document.onreadystatechange=function(){
				PG.FileSelect(inputObj,ImgObj,title)
			}
		}
	},
	UploadFile :function (){
		Element.hide('browser');
		Element.removeClassName('tab-browser','current')
		Element.show('upload')
		Element.addClassName('tab-upload','current')
	},
	BrowserFile : function(sQuery){
		new Ajax.Request('/my/MyFiles.html',{
					asynchronous:false,
					parameters: 's='+Math.random()+'&'+sQuery,
					method: 'get',
					evalJS: false,
					onSuccess: function(r) {
						PG._FileDialog.SetContent(r.responseText)
					}
				});
		Element.hide('upload');
		Element.removeClassName('tab-upload','current')
		Element.show('browser')
		Element.addClassName('tab-browser','current')
	},
	loadOptions : function(/*Object|String*/node,/*string*/ fName,/*String*/query,/*boolean*/ fuseDefault){
		var obj = (Object.isString(node))? $(node):node;
		var q = 'f='+encodeURI(fName)+'&'+query;
		var tmp = obj.innerHTML;
		obj.disabled = true;
		Element.update(obj,'<option>加载数据中...<option>');
		try{
			new Ajax.Updater(obj,'/aspx/xmlhttp.aspx',{parameters: q ,method: 'get'});
		}catch(e){
			obj.update(tmp);
			alert(e.message);
		}
		obj.disabled = false;
	},
	loadCatalog : function(fnTargetObj,fnParentObj,fuseDefault){
		this.loadOptions((typeof(fnTargetObj)=='object')?fnTargetObj:$(fnTargetObj),(typeof(fnParentObj)=='object')?fnParentObj:$(fnParentObj),'分类目录选择',0||fuseDefault);
	},
	copy2clipboard : function(ss){
     window.clipboardData.setData("text",ss);
     alert("您已经复制了本页的链接，可以直接粘贴发给您的朋友。");
	},
	getOptionValues : function(objid,textobjid,valueobjid,flag){
		flag = (flag==null)?false:flag;
		var obj =  $(objid);
		if(obj==null){if(debug)alert("对不起,对象["+objid+"]未建立");return}
		var text='';
		var values='';
		for(var i=0;i<obj.options.length;i++){
			if(flag){
				text+=","+obj.options[i].text.replace(",","");
				values+=","+obj.options[i].value.replace(",","");
			}else if(obj.selectedIndex>-1){
				text=obj.options[i].text;
				values=obj.options[i].value;
				break;
			}
		}
		$(textobjid).value=text;
        $(valueobjid).value=values;
	},
	setInnerHTML : function (el, htmlCode) {
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) {
			htmlCode = '<div style="display:none">for IE</div>' + htmlCode;
			htmlCode = htmlCode.replace(/<script([^>]*)>/gi,
										'<script$1 defer>');
			el.innerHTML = '';
			el.innerHTML = htmlCode;
			el.removeChild(el.firstChild);
		} else {
			var el_next = el.nextSibling;
			var el_parent = el.parentNode;
			el_parent.removeChild(el);
			el.innerHTML = htmlCode;
			if (el_next) {
				el_parent.insertBefore(el, el_next)
			} else {
				el_parent.appendChild(el);
			}
		}
	},
	/* －－－－－－－－－－－－－－－　表单对象处理 Form.Element　－－－－－－－－－－－－－－－*/
	// 获得CheckBox元素的值 */
	getCheckBoxValue : function(fId){
		var str ="";
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox")
			{
				if(obj[i].id==fId||obj[i].name==fId)
				{
					if(obj[i].checked&&!obj[i].disabled)
					{
						str = str + "," + obj[i].value;
					}
				}
			}
		if(str.length>0) str = str.substring(1);
		return str;
	},
	// 获得RADIO元素的值 */
	getRadioValue : function(radio) {
		if (!radio.length && radio.type.toLowerCase() == 'radio'){
			return (radio.checked)?radio.value:'';
		}
		if (radio[0].tagName.toLowerCase() != 'input' ||radio[0].type.toLowerCase() != 'radio'){
			return '';
		}
		var len = radio.length; 
		for(i=0; i<len; i++){
			if (radio[i].checked){
				return radio[i].value;
				}
			}
		return '';
	},
	pop : function(node,me,f_){
		var obj = (Object.isString(node))? $(node):node;
		obj.style.display='block';
		obj.style.position='absolute';
		var _w = obj.clientWidth ; _h = obj.clientHeight;
		Position.clone(me,obj);
		obj.style.top = (obj.offsetTop + me.offsetHeight) + 'px';
		obj.style.width = _w;
		obj.style.height = _h;
		obj.onmouseout = function(){
			obj.style.display='none';
		}
		obj.onmouseover = function(){
			obj.style.display='block';
		}
	},
	IsChecked : function(elName,imax){
		var obj	=document.getElementsByName(elName);
		var checked = false;
		imax = (imax==null)?obj.length:imax;
		var icount=0
		for(var i=0;i<obj.length;i++){
			if(obj[i].checked&&!obj[i].disabled){
				checked=true;
				icount++;
			}
			if(icount>imax){
				window.alert("您最多选择"+imax+"项.      ");
				return false;
			}
		}
		if(icount==0) window.alert("请至少选择一个");
		return checked;
	},
	/*第1参数为目录对象*/
	selectOptions : function(){
		if(arguments.length==0) return;
		var tObj = arguments[0];
		if(tObj.options.length>=this.MaxSelected){
			alert('对不起!!你只能选择'+this.MaxSelected+'项!!');
			return ;
		}
		var s = '',v = '';
		for(var i=1;i<arguments.length;i++)
		{
			if(arguments[i].selectedIndex > -1 ){
				s += arguments[i].options[arguments[i].selectedIndex].text + ' / ';
				v = arguments[i].options[arguments[i].selectedIndex].value;
			}
		}
		if(s.length>0){
			var oOption = new Option(s,v);
			tObj.options.add(oOption,-1);
		}
	},
	removeOptions : function(){
		for(var i=0;i<arguments.length;i++)
		{
			if(arguments[i].selectedIndex > -1){
				arguments[i].options[arguments[i].selectedIndex] ==null;
				arguments[i].removeChild(arguments[i].options[arguments[i].selectedIndex]);
			}
		}
	},
	// 获得Select元素的所有Options */
	getOptions : function(objid){
		var optionArray = $A($(objid));
		var text = [],value = [];
		optionArray.each(function(node){
				text.push(node.innerHTML);
				value.push(node.value);
		});
		return {text:text.join(','),value:value.join(',')};
	},
	loadVisited:function(key){
		var strCookie = this.getCookie('Visited_'+key);
		if(strCookie!=null&&$('visitedList')!=null){
			var myAjax = new Ajax.Updater('visitedList','/aspx/xmlhttp.aspx',{
																		parameters: 'f=visitedList&idlist='+strCookie+'&key='+key,
																		method: 'get',
																		evalJS: true
																		});
		}
	},
	addVisited:function(key,val){
		var strCookie = this.getCookie('Visited_'+key);
		if(strCookie!=null){
			var arrVisited = strCookie.split(',');
			var pos = arrVisited.indexOf(val)
			//if not Exists then Add
			if(pos==-1){
				if(arrVisited.length>=10) arrVisited.shift();
				arrVisited.push(val);
			}
			val=arrVisited.join(',');
		}
		this.setCookie('Visited_'+key,val,1,this._Path);
	},
	getVisitedCookie : function(key){
		this.getCookie('Visited_'+key);
	},
	clearVisitedCookie : function(key){
		this.setCookie('Visited_'+key,'',1,this._Path);
	},
	/* －－－－－－－－－－－－－－Cookie 设定　－－－－－－－－－－－－－－－*/
	setCookie : function(name, value, expires, path, domain, secure){
		var strCookie = name + "=" + value;
		
		if (expires){
			var dtmNow = new Date();
			dtmNow.setTime(dtmNow.getTime() + expires*24*60*60*1000);
			strCookie += "; expires=" + dtmNow.toGMTString();
		}
		strCookie +=  (path) ? "; path=" + path : "";
		strCookie +=  (domain) ? "; domain=" + domain : "";
		strCookie +=  (secure) ? "; secure" : "";
		document.cookie = strCookie;
	},
	getCookie : function(name){	
		var strCookies = document.cookie;
		var cookieName = name + "=";
		var intBegin, intEnd, strValue;
		intBegin = strCookies.indexOf(cookieName);
		if (intBegin == -1) return null;
		intEnd = strCookies.indexOf(";", intBegin);
		if (intEnd == -1) intEnd = strCookies.length;
		strValue = strCookies.substring(intBegin+cookieName.length,intEnd);
		return strValue;
	},
	Select : function(sName,txtId,valueId){
		if(document.readyState=='complete'){
		var tObj,vObj;
		tObj = Object.isString(txtId)?$(txtId):txtId;
		vObj = Object.isString(valueId)?$(valueId):valueId;
		
		if(tObj==null||vObj==null){
			alert('未定义的对象！！');
			return;			
		}
		if(tObj.tagName.toLowerCase()=='input'){
			sQuery = 'objText='+((vObj.value!='')?tObj.value:'')+'&objValue='+vObj.value;
		}else{
			sQuery = 'objText='+((vObj.value!='')?tObj.innerHTML:'')+'&objValue='+vObj.value;
		}
		var title = sName;
		new Ajax.Request('/aspx/xmlhttp.aspx',{parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,onComplete: function(transport) {
			var dialogSelect = _window.Open(transport.responseText,title, 'ismodal=1,button=OK|CANCEL,width=420,height=200');
			dialogSelect.OnOK = function(){
				if(tObj.tagName.toLowerCase()=='input'){
					tObj.value = $('selectedText').innerHTML;
				}else{
					tObj.innerHTML=($('selectedText').innerHTML||'选择');
				}
				vObj.value=$('selectedValue').value;
				dialogSelect.Hidden();
			}
			}});
			}else{
				document.onreadystatechange=function(){
					PG.Select(sName,txtId,valueId)
				}
		}
	},
	/*运行ajax 窗口程序*/
	Open :	function (sName,sQuery,sTitle,sFeatures){
		var _w =null;
		if(document.readyState=='complete'){
			var title = (sTitle||sName);
			new Ajax.Request('/aspx/xmlhttp.aspx',{asynchronous:false,parameters: 'f='+encodeURI(sName)+'&'+sQuery ,method: 'get',evalJS: true,onSuccess: function(transport) {_w=_window.Open(transport.responseText,title, sFeatures);}});
		}else{
			document.onreadystatechange=function(){
				_w = PG.Open(sName,sQuery,sTitle,sFeatures);
			}
		}
		return _w;
	},
	Alert: function(sContent,sTitle,sFeatures){
		return _window.open(sContent,(sTitle||'提示'),sFeatures+',resize=no');
	},
	/*运行页面ajax指令*/
	doCmd : function(/*String*/fCmd,/*String*/sQuery,/*boolean?*/fIsAlert){
			if(fCmd.indexOf('删除')>-1){
				if(!window.confirm('执行['+fCmd+'],将删除数据(不可恢复)？'))
				return false;
			}
		var q = 'f='+encodeURI(fCmd)+'&'+sQuery;
		this.IsAlert = fIsAlert;
		var rtnValue = false;
		var myAjax = new Ajax.Request('/aspx/xmlhttp.aspx',{asynchronous:false,parameters: q ,method: 'get',
																	onComplete:function(r){
																		/*处理返回的数据*/
																		rtnValue =  this.doResult(r.responseText);
																	}.bind(this)});
		return rtnValue;
	},
	doConfirmCmd : function(/*String*/fCmd,/*String*/sQuery,/*boolean?*/fIsAlert){
		if(window.confirm('是否确定('+fCmd+')？'))
			return  this.doCmd(fCmd,sQuery,fIsAlert);
	},
	doResult: function(fC){
		if(!fC){alert("提交服务器操作失败,请联系管理员!!!     ");return false;}
		try{
			if(fC.split(",")[0].toString()=='1'||fC.split(",")[0].toString()=='2'){
				var message="操作成功!!!";
				if(fC.split(",").length>1)
					if(fC.split(",")[1].toString().length>0)
						var message=fC.split(",")[1].toString();
				/*是否回显提示*/
				if(this.IsAlert) alert(message);//_window.Alert(message, '提示');
				return true;
			}else if(fC.split(",")[0].toString()=='102'){
				alert('找不到此更新的内容！！！('+fC.split(",")[0]+')');
				return false;
			}else if(fC.split(",")[0].toString()=='403'){
				this.doLogin();
				return false;
			}else if(fC.split(",")[0].toString()=='103'){
				if($('vCodeLine')) $('vCodeLine').style.display='';
				alert('验证码填写出错，请检查！！！('+fC.split(",")[0]+')');
				return false;
			}else{
				if(fC.split(",").length>1) var message = fC.split(",")[1].toString()
				//_window.Alert(message + "("+ fC.split(",")[0].toString() + ")", '提示','resize=no');
				alert(message + "("+ fC.split(",")[0].toString() + ")");
				return false;
			}
		}catch(e){alert(e.message);}
		return false;
	},
	doLogin : function(){
		alert('你还未登录系统,请登录后操作！！');
	},
	/* 复选框 全选 / 取消 /反选*/
	CheckBoxSelect : function(fId,flag){
		var obj=document.getElementsByTagName("INPUT");
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=="checkbox"&&!obj[i].disabled)
			{
				if((!fId)||obj[i].id==fId||obj[i].name==fId){
					if(flag==2)
					{
						obj[i].checked=!obj[i].checked;
					}else{
						obj[i].checked=flag;
					}
				}
			}
	},
	doError : function(/*string*/text){
		alert(text)
	}	
}

PG.SWFPlayer = function(/*Object Id*/Obj,swf_width,swf_height){
	if(Object.isString(Obj)) Obj=$(Obj);
	if(Obj==null) return;
	Element.hide(Obj);
	var files='',links='',texts='';
	$$('#'+Obj.id+' ul li a').each(
		function(item){
			texts+=((texts=='')?'':'|')+item.title;
			links+=((links=='')?'':'|')+item.href;
		}
	)
	$$('#'+Obj.id+' ul li img').each(
		function(item){
			files+=((files=='')?'':'|')+item.src;
		}
	)
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
	document.write('<param name="movie" value="/swf/bcastr3.swf"><param name="quality" value="high">');
	document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
	document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
	document.write('<embed src="/swf/bcastr3.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); 
	document.write('</object>'); 
}
var Tween = {
	Quart: {
		easeOut: function(t,b,c,d){
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		}
	},
	Back: {
		easeOut: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		}
	},
	Bounce: {
		easeOut: function(t,b,c,d){
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		}
	}
}
var SlideTrans = function(container, slider, count, options) {
    this._slider = $(slider);
    this._container = $(container);//容器对象
    this._timer = null;//定时器
    this._count = Math.abs(count);//切换数量
    this._target = 0;//目标值
    this._t = this._b = this._c = 0;//tween参数
    
    this.Index = 0;//当前索引
	this.timer = [];
    
    this.SetOptions(options);
    
    this.Auto = !!this.options.Auto;
    this.Duration = Math.abs(this.options.Duration);
    this.Time = Math.abs(this.options.Time);
    this.Pause = Math.abs(this.options.Pause);
    this.Tween = this.options.Tween;
    this.onStart = this.options.onStart;
    this.onFinish = this.options.onFinish;
    
    var bVertical = !!this.options.Vertical;
    this._css = bVertical ? "top" : "left";//方向
    
    //样式设置
    var p = Element.getStyle(this._container,'position');
    p == "relative" || p == "absolute" || (this._container.style.position = "relative");
    this._container.style.overflow = "hidden";
    this._slider.style.position = "absolute";
    this.initNum();
    this.Change = this.options.Change ? this.options.Change :
        this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
}
SlideTrans.prototype = {
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
        Vertical:    true,//是否垂直方向（方向不能改）
        Auto:        true,//是否自动
        Change:        0,//改变量
        Duration:    50,//滑动持续时间
        Time:        0,//滑动延时
        Pause:        1000,//停顿时间(Auto为true时有效)
        onStart:    function(){},//开始转换时执行
        onFinish:    function(){},//完成转换时执行
        Tween:        Tween.Quart.easeOut//tween算子
    };
    Object.extend(this.options, options || {});
  },
  //开始切换
  Run: function(index) {
    //修正index
    index == undefined && (index = this.Index);
    index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
    //设置参数
    this._target = -Math.abs(this.Change) * (this.Index = index);
    this._t = 0;
    this._b = parseInt(this._slider.style[this.options.Vertical ? "top" : "left"]);
    this._c = this._target - this._b;
    this.onStart();
    this.Move();
  },
  initNum : function(){
	  var ul = document.createElement('div');
	  ul.className = 'num';
	  for(var i=1;i<=this._count;i++){
		  var li = document.createElement('a');
		  li.innerHTML = i;
		  li.onmouseover = function(li,i){
			  this._timer = setTimeout(function(li,i){  this.Auto = false; this.Run(i); }.bind(this,li,i), 100);
		  }.bind(this,li,i);
		  li.onmouseout = function(li,i){
			  clearTimeout(this._timer);  this.Auto = true; this.Run();
		  }.bind(this,li,i)
		  Insertion.Bottom(ul,li);
		  Element.setStyle(li,{	float: 'left',display:'block'});
	  }
	  Insertion.Bottom(this._container,ul);
	  Element.setStyle(ul,{position:'absolute', right:'5px', bottom:'5px', font:'12px/1.5 tahoma, arial', height:'18px'});
  },
  //移动
  Move: function() {
    clearTimeout(this._timer);
    //未到达目标继续移动否则进行下一次滑动
    if (this._c && this._t < this.Duration) {
        this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
        this._timer = setTimeout(this.Move.bind(this), this.Time);
    }else{
        this.MoveTo(this._target);
        this.Auto && (this._timer = setTimeout( this.Next.bind(this), this.Pause));
    }
  },
  //移动到
  MoveTo: function(i) {
    this._slider.style[this._css] = i + "px";
  },
  //下一个
  Next: function() {
    this.Run(++this.Index);
  },
  //上一个
  Previous: function() {
    this.Run(--this.Index);
  },
  //停止
  Stop: function() {
    clearTimeout(this._timer); this.MoveTo(this._target);
  }
}
/*******************************************************************/
function Slider(container, frequency, direction) {
  if (typeof(container) == 'string') {
    container = $(container);
  }
  this.container = container;
  this.frequency = frequency;
  this.direction = direction;
  this.films = [];
  this._playTimeoutId = null;
  this._slideTimeoutId = null;
  this._slidable = true;
	this._current = 0;

  var divs = this.container.getElementsByTagName('dl');
  for (var i = 0; i < divs.length; i++) {
      divs[i].onmouseover = function(self){return function(){self._mouseover()};}(this);
      divs[i].onmouseout = function(self){return function(){self._mouseout()};}(this);
  }
  this._loop();
}

Slider.prototype = {
  _loop : function() {
    var sb = this;
    this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency);
  },

  _slide : function() {
    var sb = this;
		//$('test').innerHTML+=sb.container.id+'='+sb._slidable+'<br/>';
		if(sb._slidable){
			var c = sb.container;
			Effect.Fade(c.getElementsByTagName('dl')[this._current],{duration:1,from:0.8,to:0});
			this._current++;
			if(this._current>=c.getElementsByTagName('dl').length){
					this._current=0
			}
			Effect.Appear(c.getElementsByTagName('dl')[this._current]);
		}
    this._playTimeoutId = setTimeout(function(){sb._slide()}, this.frequency);
  },

  _mouseover : function() {
    this._slidable = false;
  },

  _mouseout : function() {
    this._slidable = true;
  }
}
/********* 星级评分 V1.0 Powered By Leo 2010/10/28**************/
_star_ = Class.create();
_star_.prototype.initialize = function(opts){
	opts = opts || {};
	this.input = opts.input ;
	this.className = opts.className || 'star_';
	this.value = opts.value || 0;	//返回值
	this.maxValue = opts.maxValue || 5;
	this.minValue = opts.minValue || 0;
	this.htmlControl = opts.html ;
	this.inputControl = opts.input ;
	this.stepValue = opts.stepValue || 1;
	this.star = opts.star || '/images/common/star_rating2.gif';
	this.selected = false;
	this.initStar($(opts.container),$(opts.slider));
}
_star_.prototype.initStar = function(container,slider){
	this.container = container || document.createElement('div')
	this.slider = slider || document.createElement('span');
	Insertion.Top(this.container,this.slider)
	this.setSelectedValue(this.value);
	
	var percent = (this.selectedValue/this.maxValue*100);
	
	Element.setStyle(this.slider,{
		display:'block'
		,width:percent+'%'
		,height:Element.getHeight(this.container) +'px'
		,textIndent:'-10000px'
		});
	
	Event.observe(this.container,'click',function(e){
		/*if(this.selected){*/
			this.onSliderChange(e);
			this.value = this.selectedValue;
	/*	}*/
		}.bind(this));		
	Event.observe(this.container,'mousemove',function(e){
		/*if(this.selected){*/
			this.onSliderChange(e);
	/*	}*/
		}.bind(this));
	Event.observe(this.container,'mouseout',function(e){
		tmp = (this.value/this.maxValue)*100;;
		Element.setStyle(this.slider,{
			width:tmp+'%'
			});
		this.setSelectedValue(this.value);
	}.bind(this));
}
_star_.prototype.onSliderChange = function(e){
	step = (this.stepValue/this.maxValue)*100;
	tmp = Math.ceil((Event.pointerX(e)-Element.cumulativeOffset(this.container).left)/this.container.offsetWidth*100/step)*step;
	value = tmp/100 * this.maxValue;
	Element.setStyle(this.slider,{
		width:tmp+'%'
		});
	this.setSelectedValue(value);
}


_star_.prototype.setSelectedValue = function(value){
	this.selectedValue = value;	//待选值
	this.container.title=value;
	Element.update(this.slider,value);
	this.onChange();
}
_star_.prototype.setValue = function(){
	this.value = this.selectedValue;
}
//待选值修改事件
_star_.prototype.onChange = function(){
	if(this.htmlControl&&$(this.htmlControl))	Element.update(this.htmlControl,this.selectedValue);
	if(this.inputControl&&$(this.inputControl)) this.inputControl.value = this.selectedValue;
}
//点击事件
_star_.prototype.onClick = function(value){
	this.setValue(value);
}
_star_.prototype.getValue = function(){
	return this.value;
}
/********* 弹出层 V0.8 Powered By Leo 2010/06/11**************/
_window_zIndex_ = 100
_window_ = Class.create();
_window_.prototype.initialize = function(ops_Features){
	ops_Features = (ops_Features==null)?{}:ops_Features;
	this.className = ops_Features.className || 'dooll';
	this.width = ops_Features.width || 300;
	this.isModal = ops_Features.isModal || false;
	this.resize = ops_Features.resize || false;
	this.draggable = ops_Features.draggable || false;
	this.buttons = ops_Features.buttons || {enabled:false};
	this.zIndex = 100;
}
_window_.prototype.setOptions = function(options){
	
}
_window_.open=function(content,title,features)
{
	var obj=new _window_(features);
	obj.create(content,title);
	return obj;
}

_window_.alert=function(content,title,features)
{
	features = features || {};
	features.isModal = true;
	features.buttons = {enabled:true,OK:true};

	var obj= new _window_(features);
	obj.create(content,title||"Alert");
	return obj;
}

_window_.confirm=function(content,title,features)
{
	features = features || {};
	features.isModal = true;
	features.buttons = {enabled:true,OK:true,Cancel:true};
	
	var obj=new _window_(features);
	obj.create(content,title||"Confirm");
/*	obj.buttons["CANCEL"].focus();*/
	return obj;
}

_window_.prototype.create=function(content,title)
{


	/*对象创建*/
	this.divContainer=document.createElement("div");
	this.divTitle=document.createElement("div");
	this.divContent=document.createElement("div");
	this.divTitleContent=document.createElement("div");
	this.spanClose=document.createElement("span");

	Insertion.Bottom(this.divTitle,this.spanClose);
	Insertion.Bottom(this.divTitle,this.divTitleContent);
	
	Insertion.Bottom(this.divContainer,this.divTitle);
	Insertion.Bottom(this.divContainer,this.divContent);
	
	Insertion.Bottom(document.body,this.divContainer);
	
	/*内容容器*/
	
	Element.addClassName(this.divContainer,'window_');
	Element.addClassName(this.divContainer,this.className);
	Element.setStyle(this.divContainer,{
					 width:  this.width + 'px',
					 //height: this.height + 'px',
					 position : 'absolute',
					 zIndex : this.zIndex,
					 backgroundColor:'#999'
					 });

	//标题栏

	this.divTitle.className='title_';
	

	this.divTitleContent.className='titleContent_';
	this.divTitleContent.innerHTML = title || 'title';


	this.spanClose.className='close_';
	this.spanClose.innerHTML='&nbsp;';
	Event.observe(this.spanClose,'click',this.close.bind(this));
	Event.observe(this.spanClose,'mouseover',function(){Element.addClassName(this,'hover')});
	Event.observe(this.spanClose,'mouseout',function(){Element.removeClassName(this,'hover')});

	
	this.divTitle.onselectstart = function(){return false;}
	
	//内容
	
	this.divContent.className='content_';
	Element.update(this.divContent,content);

	//样式
	Element.setStyle(this.spanClose,{
					 float: 'right'
					 ,display : 'block'
					 ,cursor: 'default'
					 ,width:'26px'
					 });
	Element.setStyle(this.divTitleContent,{
					 float: 'left'
					 ,cursor: 'default'
					 ,overflow: 'hidden'
					 ,whiteSpace: 'nowrap'
					 ,width: (Element.getWidth(this.divTitle)-70) +'px'
					 });
	

	Event.observe(window,'scroll',this.onScroll.bind(this));
	Event.observe(window,'resize',this.onResize.bind(this));

	if(this.isModal){
		/* Modal 层*/
		this.modal=document.createElement("div");
		this.modal.className="Modal_";
		Element.update(this.modal,'<iframe></iframe>');
		Insertion.Bottom(document.body,this.modal);
		Element.setStyle(this.modal,{
					 zIndex : 0,
					 left : 0,
					 top : 0,
					 position : "absolute",
					 overflow: 'hidden'
					 });
	}
	//new Effect.Opacity(this.divContainer,{from:0.0,to:1.0}); 
	this.onResize();
	this.onScroll();
	//this.setDraggable(this.draggable);

	if(this.buttons.enabled) this.enabledButtons();
}
_window_.prototype.enabledButtons = function(){
	this.divButtons=document.createElement("div");
	this.divButtons.className ='buttons_';
	if(this.buttons.OK){
		this.buttonOK = document.createElement("div");
		this.buttonOK.innerHTML="&nbsp;";
		this.buttonOK.className = 'OK_';
		Insertion.Bottom(this.divButtons,this.buttonOK);
		Event.observe(this.buttonOK,'click',function(){
													this.OnOK()
													}.bind(this)
													);
		Element.setStyle(this.buttonOK,{
						 float:'right'
						 });
		Insertion.Bottom(this.divButtons,this.buttonOK);
	}
	Insertion.Bottom(this.divContainer,this.divButtons);
}
_window_.prototype.OnOK = function(){
	this.close();
}
_window_.prototype.setContent=function(content){
	if(this.divContent)
		Element.update(this.divContent,content);
	else
		this.create(content);
}
_window_.prototype.setResponseContent=function(title,r){
	this.setContent(r.responseText);
	this.setTitle(title);
}
_window_.prototype.loadContent=function(title,fName,query,bAsyn){
	PG.loadFuncContent(this.setResponseContent.bind(this,title),fName,query,bAsyn);
}
_window_.prototype.loadObject=function(title,obj,isCopy){
	var obj = Object.isString(obj)?$(obj):obj;
	if(!isCopy) {Element.hide(obj);Element.remove(obj)}
	this.setContent(obj.innerHTML)
	this.setTitle(title);
}
/*加载远程*/
_window_.prototype.loadUrl=function(title,url,query,bAsyn){
	new Ajax.Request(url,{
		asynchronous:bAsyn&&true,
		evalScripts:true,
		parameters: query +'?'+Math.random(),
		method: 'get',
		onSuccess: this.setResponseContent.bind(this,title)
		});
}
_window_.prototype.setTitle = function(title){
	if(this.divTitleContent){
		Element.update(this.divTitleContent,title);
	}
}
_window_.prototype.setDraggable = function(status){
	if(status)
		this.dragContainer = new Draggable(this.divContainer,{handle:'title_'});
	else if(this.dragContainer){
		this.dragContainer.destroy();
	}
}
_window_.prototype.onScroll=function(){
	var scrollvalue = Position.realOffset(document.documentElement);
	Element.setStyle(this.divContainer,{
					 left:  (this.left+scrollvalue.left) + 'px',
					 top: (this.top+scrollvalue.top) + 'px'
					 });
}

_window_.prototype.close = function(){
	this.OnClose();
	if(this.isModal) Element.hide(this.modal)
	Element.hide(this.divContainer)
	this.remove();
}
_window_.prototype.OnClose=function(){
}
_window_.prototype.remove = function(){
	if(this.isModal){Element.remove(this.modal);this.modal=null}
	Element.remove(this.divContainer)
}
_window_.prototype.onResize = function(){
	var w = document.documentElement.clientWidth //Element.getWidth(document.documentElement);
	var h = document.documentElement.clientHeight//Element.getHeight(document.documentElement);
	if(this.isModal){
		Element.setStyle(this.modal,{
					 width : w +'px',
					 height : Math.max(h,document.documentElement.scrollHeight)  +'px'
					 });
	}
	this.left = (w - Element.getWidth(this.divContainer)) /2 
	this.top = Math.max(0,(h - Element.getHeight(this.divContainer)-50) /2)
	Element.setStyle(this.divContainer,{
					 left:  this.left + 'px',
					 top: this.top + 'px'
					 });
	
}

/********* 颜色选择器 V1.0 Powered By Leo 2009/03/11**************/
function ColorTable(instance){
	this.Instance = new String(instance);
	this.Color = "#000000";
	this.Callback = null;
	var flag = -1;
	var PreviewCellID = Global.GetUniqueID();
	var RGBID = Global.GetUniqueID();
	var LayerID = Global.GetUniqueID();
	var Colors = "#000000,#000000,#000000,#000000,#003300,#006600,#009900,#00cc00,#00ff00,#330000,#333300,#336600,#339900,#33cc00,#33ff00,#660000,#663300,#666600,#669900,#66cc00,#66ff00,#000000,#333333,#000000,#000033,#003333,#006633,#009933,#00cc33,#00ff33,#330033,#333333,#336633,#339933,#33cc33,#33ff33,#660033,#663333,#666633,#669933,#66cc33,#66ff33,#000000,#666666,#000000,#000066,#003366,#006666,#009966,#00cc66,#00ff66,#330066,#333366,#336666,#339966,#33cc66,#33ff66,#660066,#663366,#666666,#669966,#66cc66,#66ff66,#000000,#999999,#000000,#000099,#003399,#006699,#009999,#00cc99,#00ff99,#330099,#333399,#336699,#339999,#33cc99,#33ff99,#660099,#663399,#666699,#669999,#66cc99,#66ff99,#000000,#cccccc,#000000,#0000cc,#0033cc,#0066cc,#0099cc,#00cccc,#00ffcc,#3300cc,#3333cc,#3366cc,#3399cc,#33cccc,#33ffcc,#6600cc,#6633cc,#6666cc,#6699cc,#66cccc,#66ffcc,#000000,#ffffff,#000000,#0000ff,#0033ff,#0066ff,#0099ff,#00ccff,#00ffff,#3300ff,#3333ff,#3366ff,#3399ff,#33ccff,#33ffff,#6600ff,#6633ff,#6666ff,#6699ff,#66ccff,#66ffff,#000000,#ff0000,#000000,#990000,#993300,#996600,#999900,#99cc00,#99ff00,#cc0000,#cc3300,#cc6600,#cc9900,#cccc00,#ccff00,#ff0000,#ff3300,#ff6600,#ff9900,#ffcc00,#ffff00,#000000,#00ff00,#000000,#990033,#993333,#996633,#999933,#99cc33,#99ff33,#cc0033,#cc3333,#cc6633,#cc9933,#cccc33,#ccff33,#ff0033,#ff3333,#ff6633,#ff9933,#ffcc33,#ffff33,#000000,#0000ff,#000000,#990066,#993366,#996666,#999966,#99cc66,#99ff66,#cc0066,#cc3366,#cc6666,#cc9966,#cccc66,#ccff66,#ff0066,#ff3366,#ff6666,#ff9966,#ffcc66,#ffff66,#000000,#ffff00,#000000,#990099,#993399,#996699,#999999,#99cc99,#99ff99,#cc0099,#cc3399,#cc6699,#cc9999,#cccc99,#ccff99,#ff0099,#ff3399,#ff6699,#ff9999,#ffcc99,#ffff99,#000000,#00ffff,#000000,#9900cc,#9933cc,#9966cc,#9999cc,#99cccc,#99ffcc,#cc00cc,#cc33cc,#cc66cc,#cc99cc,#cccccc,#ccffcc,#ff00cc,#ff33cc,#ff66cc,#ff99cc,#ffcccc,#ffffcc,#000000,#ff00ff,#000000,#9900ff,#9933ff,#9966ff,#9999ff,#99ccff,#99ffff,#cc00ff,#cc33ff,#cc66ff,#cc99ff,#ccccff,#ccffff,#ff00ff,#ff33ff,#ff66ff,#ff99ff,#ffccff,#ffffff".split(",");
	this.ShowTable = function(callBack,x,y){
		if(flag != 1){
			return;
		}
		if("function" != typeof(callBack)) return;
		this.Callback = callBack;
		document.getElementById(LayerID).style.display = "";
		document.getElementById(LayerID).style.top = parseInt(y,10);
		document.getElementById(LayerID).style.left = parseInt(x,10);
	}
	
	this.Init = function(){
		if(flag != (-1)){
			return;
		}
		if(window[this.Instance] != this){
			throw new Error(-1,"");
		}
		flag = 0;
	}
	this.SetColor = function(color){
		if(flag != 1){
			return;
		}
		this.Color = new String(color).toUpperCase();
		document.getElementById(PreviewCellID).style.backgroundColor = this.Color;
		document.getElementById(RGBID).innerHTML = this.Color;
	}
	
	this.Select =  function(color){
		if(flag != 1){
			return;
		}
		this.Color = new String(color).toUpperCase();
		if("function" == typeof(this.Callback))
			this.Callback(this.Color);
		this.Hide();
	}
	this.Draw = function(){
		if(flag == (-1)){
			this.Init();
		}
		if(flag != 0){
			return ;
		}
		var shtml = "";
		shtml += '<div id="' + LayerID + '" style="position:absolute;display:none;top:0px;left:0px;width:214px;height:145px;overflow:visible;border:0px;z-index:999999;">';
		shtml += this.GetTable();
		shtml += '</div>';
		
		document.write(shtml);
		flag = 1;
	}
	
	this.Hide = function(){
		if(flag != 1){
			return;
		}
		document.getElementById(LayerID).style.display = "none";
	}
	this.GetTable = function(){
		var shtml = '\
			<table width="214" onmousedown="event.cancelBubble=true;" height="145" border="0" cellpadding="0" cellspacing="0" style="border:solid 1px #000000">\n\
			<tr>\n\
				<td height="20" bgcolor="#D4D0C8" scope="col"><table width="100%" style="margin:2px;" border="0" cellspacing="0" cellpadding="0">\n\
				<tr>\n\
					<td width="24%" height="20" style="background-color:#ffffff;border:solid 1px #000000" scope="col" id="' + PreviewCellID + '">&nbsp;</td>\n\
					<td width="43%" height="20" scope="col"><div align="center" style="font-family:宋体;font-size:9pt;" id="' + RGBID + '"></div></td>\n\
					<td width="33%" height="20" scope="col"><div align="center"></div></td>\n\
				</tr>\n\
				</table></td>\n\
			</tr>\n\
			<tr>\n\
				<td>';
		shtml += '<table border="0" cellspacing="1" bgcolor="#000000">';
		shtml += '<tr height="10">';
		for(var i=0,l=Colors.length;i<l;i++){
			if(i%21 == 0){
				shtml += "</tr><tr>";
			}
			shtml += '<td height="10" width="10" bgcolor="' + Colors[i] + '" style="cursor:hand;" onmouseover="' + this.Instance + '.SetColor(bgColor)" onmousedown="' + this.Instance + '.Select(bgColor)"></td>';
		}
		shtml += '</table>';
		shtml += '	</td>\n\
					</tr>\n\
				</table>';
		return shtml;
	}
}

/* 	Div 选择器 V0.4 2010-06-11 Powerby Leo */
_SelecterID = 100;
_Selecter_ = Class.create();

_Selecter_.prototype.initialize = function(obj, opt_Options){
	
	opt_Options = opt_Options || {};
	
	this.listSize = opt_Options.ListSize || 4;
	/**/
	this.obj = $(obj);

	this.obj.style.display = 'none';
	
	this.selectedItem = null;
	
	this.selectedText = this.obj.options[this.obj.selectedIndex].text;

	/*容器层*/
	this.oContainer_ = document.createElement("div");
	this.oContainer_.className = 'divselect';
	Element.setStyle(this.oContainer_,{
					 position:'relative',
					 cursor:'pointer'
					 });
	
	/*容器标题层*/
	this.oText_ = document.createElement("div");	
	
	this.oText_.className = 'dt';
	Element.update(this.oText_,this.selectedText);
	Insertion.Bottom(this.oContainer_,this.oText_);
	
	/*下拉选择层*/
	
	this.oSelecter_ = document.createElement("div");
	this.oSelecter_.className = 'dd';

	this.oSelecter_.style.height=(opt_Options.selecterHeight)?opt_Options.selecterHeight+'px':'auto';
	this.oSelecter_.style.overflow='auto';
	Insertion.Bottom(this.oContainer_,this.oSelecter_);
	
	Event.observe(this.oText_,'mouseover',this.showSelecter.bind(this));
	Event.observe(this.oText_,'mouseout',this.hideSelecter.bind(this));
	Event.observe(this.oSelecter_,'mouseover',this.showSelecter.bind(this));
	Event.observe(this.oSelecter_,'mouseout',this.hideSelecter.bind(this));
	Event.observe(document,'click',this.hideSelecter.bind(this));
	
	this.createOptions(this.obj);
	
	Insertion.After(obj,this.oContainer_);
	var top = Element.getHeight(this.oText_);
	Element.setStyle(this.oSelecter_,{
					 display:'none',
					 position:'absolute',
					 left:'-1px',
					 top:(top+1)+'px'
					 });
	return this.oContainer_;
}
_Selecter_.prototype.showSelecter = function(){
	Element.show(this.oSelecter_)
}
_Selecter_.prototype.hideSelecter = function(){
	Element.hide(this.oSelecter_)
}
_Selecter_.prototype.createOptions=function(){
	Element.update(this.oSelecter_,'');
	for(var i=0;i<this.obj.childNodes.length;i++){
		var li = document.createElement("a");
		if(this.obj.childNodes[i].nodeType==1){
			li.innerHTML = this.obj.childNodes[i].innerHTML;
			if(this.selectedText ==li.innerHTML){
				Element.setStyle(li,{
								 fontWeight:'bold'
								 });
				this.selectedItem = li;
			}
			Element.setStyle(li,{
								 display:'block'
								 });
			li.rel = this.obj.childNodes[i].value;
			li.href= "javascript:void(0)";
			var callback = (typeof(this.obj.onchange)=='function')?this.obj.onchange.bind(this.obj):null
			li.onclick = this.OptionChange.bind(this,li,callback);
			Insertion.Bottom(this.oSelecter_,li);
		}
	}

}

_Selecter_.prototype.OptionChange=function(item,callback){
	if(this.selectedItem!=null)this.selectedItem.style.fontWeight='';
	item.style.fontWeight='bold';
	this.obj.value = item.rel;
	this.selectedItem = item;
	this.oText_.innerHTML = item.innerHTML;
	Element.hide(this.oSelecter_);
	if(typeof(callback)=='function'){
		callback();
	}
}
/**************Tips******************/
_Tip_= Class.create();
_Tip_.prototype.initialize=function(item,foritem){
	Event.observe(foritem,'mouseover',this.show.bind(item,window.event));
	Event.observe(foritem,'mouseout',this.hide.bind(item,window.event));
}
_Tip_.prototype.show=function(evt){
	//alert(Event.pointerX(evt));
	Element.setStyle(this,{
					 position: 'absolute',
					 left:Event.pointerX(evt),
					 top: Event.pointerY(evt)
					 });
	Element.show(this);
}

_Tip_.prototype.hide=function(item){
	Element.hide(this);
}

tabManage = Class.create();
tabManage.prototype.initialize=function(item,opts){
	
	
	if(item.select('.title li[class!=\'more\']').length==0||item.select('.content')==null) return;
	
	opts = opts || {};
	this.title = item.select(opts.titleCss || '.title li');
	this.contents = item.select(opts.contentCss || '.content[class!="content f14"]');
	this.initEvent();
}
tabManage.prototype.initEvent=function(){
	for(var i=0;i<this.title.length;i++){
		//if(!Element.hasClassName(this.title[i],'more'))
		Event.observe(this.title[i], 'mouseover', this.onClick.bind(this,i));
	}
}
tabManage.prototype.onClick = function(j,e){
	for(var i=0;i<this.title.length;i++){
		if(i==j){
			this.title[i].addClassName('check');
			if(i<this.contents.length)
				Element.setStyle(this.contents[i],{display:'block'});
		}else{
			this.title[i].removeClassName('check');
			if(i<this.contents.length)
				Element.setStyle(this.contents[i],{display:'none'});
		}
	}
	
	Event.stop(e);
}